/*******************************************************************************
 * Copyright (c) 2010 L.Carbonnaux.
 *******************************************************************************/

package org.lcx.taskvision.ui;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.LegendElement;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.NewTaskWizard;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
import org.lcx.taskvision.core.TaskVisionCorePlugin;
import org.lcx.taskvision.ui.wizzard.TaskVisionQueryWizardPage;
import org.lcx.taskvision.ui.wizzard.TaskVisionRepositorySettingsPage;


/**
 * @author Laurent Carbonnaux
 */
public class TaskVisionConnectorUi extends AbstractRepositoryConnectorUi {

	@Override
	public String getConnectorKind() {
		return TaskVisionCorePlugin.CONNECTOR_KIND;
	}

	@Override
	public String getTaskKindLabel(ITask task) {
		return Messages.ScrumVisionConnectorUi_task;
	}
	
	@Override
	public ImageDescriptor getTaskKindOverlay(ITask task) {
		ImageDescriptor overlayImage = TaskVisionImages.OVERLAY_TASK;
		
		if(overlayImage==null) overlayImage = super.getTaskKindOverlay(task);

		return overlayImage;
	}
	
	@Override
	public List<LegendElement> getLegendElements() {
		List<LegendElement> legendElements = new ArrayList<LegendElement>();

		legendElements.add(LegendElement.createTask(Messages.ScrumVisionConnectorUi_task, TaskVisionImages.OVERLAY_TASK));

		return legendElements;
	}
	
	@Override
	public boolean hasSearchPage() {
		return false;
	}

	@Override
	public IWizard getNewTaskWizard(TaskRepository taskRepository, ITaskMapping selection) {
		return new NewTaskWizard(taskRepository, selection);
	}

	@Override
	public IWizard getQueryWizard(TaskRepository repository, IRepositoryQuery query) {
		RepositoryQueryWizard wizard = new RepositoryQueryWizard(repository);
		wizard.addPage(new TaskVisionQueryWizardPage(repository, query));
		return wizard;
	}

	@Override
	public ITaskRepositoryPage getSettingsPage(TaskRepository taskRepository) {
		return new TaskVisionRepositorySettingsPage(taskRepository);
	}

}
